﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMaster.Master" AutoEventWireup="true" CodeBehind="AdminAdmin.aspx.cs" Inherits="TravelLink.WebApp.Admin.AdminAdmin" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPopupControl" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView.Export" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
var rid;
function CallServer()
{
var rowid = rid+','+atbPassword.GetText();
<%= ClientScript.GetCallbackEventReference(this, "rowid", "ReceiveServerData",null)%>;
}
 
function ReceiveServerData(rValue)
{
    if(rValue=='')
    {
 	popChangePassword.Hide();
    atbPassword.SetText('');
    atbConfirm.SetText('');
    alert('修改成功');
    }
    else
    {
    alert(rValue);
    }
}
 </script>
<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .style2
    {
        width: 100px;
    }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1">
    <tr>
        <td class="style2">
            <dx:ASPxButton ID="ASPxButton2" runat="server" AutoPostBack="False" Text="新增">
                <ClientSideEvents Click="function(s, e) {
	agv.AddNewRow();
}" />
            </dx:ASPxButton>
        </td>
        <td>
            <dx:ASPxButton ID="abtnExport" runat="server" Text="导出excel" 
                onclick="abtnExport_Click">
            </dx:ASPxButton>
            
        </td>
    </tr>
</table>
    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="ldsAdmin" KeyFieldName="Idx" 
        onrowvalidating="ASPxGridView1_RowValidating" ClientInstanceName="agv">
        <ClientSideEvents CustomButtonClick="function(s, e) {
	                rid=e.visibleIndex;
	popChangePassword.Show();
}" />
        <Columns>
            <dx:GridViewCommandColumn ButtonType="Button" Caption="操作" VisibleIndex="8">
                <EditButton Text="修改" Visible="True">
                </EditButton>
                <NewButton Text="新增">
                </NewButton>
                <DeleteButton Text="删除" Visible="True">
                </DeleteButton>
                <CancelButton Text="取消" Visible="True">
                </CancelButton>
                <UpdateButton Text="保存" Visible="True">
                </UpdateButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
                <CustomButtons>
                    <dx:GridViewCommandColumnCustomButton Text="修改密码">
                    </dx:GridViewCommandColumnCustomButton>
                </CustomButtons>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="Idx" ReadOnly="True" 
                ShowInCustomizationForm="True" Visible="False" VisibleIndex="10">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="角色" FieldName="FK_RoleID" 
                VisibleIndex="1" Width="80px">
                <PropertiesComboBox DataSourceID="ldsRole" TextField="Name" ValueField="Idx" 
                    ValueType="System.String">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn Caption="姓名" FieldName="Name" 
                ShowInCustomizationForm="True" VisibleIndex="3" Width="80px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="部门" FieldName="Department" 
                ShowInCustomizationForm="True" VisibleIndex="2" Width="80px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Password" ShowInCustomizationForm="True" 
                Visible="False" VisibleIndex="9">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="登录名" FieldName="UserCode" 
                ShowInCustomizationForm="True" VisibleIndex="4" Width="100px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Email" ShowInCustomizationForm="True" 
                VisibleIndex="5" Width="100px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="电话" FieldName="TelePhone" 
                ShowInCustomizationForm="True" VisibleIndex="6" Width="100px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="手机" FieldName="MobilePhone" 
                ShowInCustomizationForm="True" VisibleIndex="7" Width="100px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataCheckColumn Caption="可登录" FieldName="Enable" 
                ShowInCustomizationForm="True" VisibleIndex="0">
            </dx:GridViewDataCheckColumn>
        </Columns>
        <Settings ShowFilterRow="True" />
    </dx:ASPxGridView>
    <dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server" 
                ClientInstanceName="popChangePassword" HeaderText="修改密码" 
    Modal="True" PopupHorizontalAlign="WindowCenter" 
    PopupVerticalAlign="WindowCenter">
                <ContentCollection>
<dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
    <asp:Panel ID="Panel1" runat="server">
        <table class="style1">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="输入密码" Width="60px"></asp:Label>
                </td>
                <td>
                    <dx:ASPxTextBox ID="atbPassword" runat="server" Width="150px" 
                        ClientInstanceName="atbPassword" Password="True">
                    </dx:ASPxTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label2" runat="server" Text="再输一次" Width="60px"></asp:Label>
                </td>
                <td>
                    <dx:ASPxTextBox ID="atbConfirm" runat="server" Width="150px" 
                        ClientInstanceName="atbConfirm" Password="True">
                    </dx:ASPxTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <dx:ASPxButton ID="ASPxButton1" runat="server" Text="确认修改" 
                        AutoPostBack="False">
                        <ClientSideEvents Click="function(s, e) {
	if(atbPassword.GetText()!=atbConfirm.GetText())
	{
		alert('两次输入的密码不一致');
	}
	else
	{
		CallServer();
	}
}" />
<ClientSideEvents Click="function(s, e) {
	if(atbPassword.GetText()!=atbConfirm.GetText())
	{
		alert(&#39;两次输入的密码不一致&#39;);
	}
	else
	{
		CallServer();
	}
}"></ClientSideEvents>
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
    </asp:Panel>
                    </dx:PopupControlContentControl>
</ContentCollection>
            </dx:ASPxPopupControl>
    <asp:LinqDataSource ID="ldsRole" runat="server" 
        ContextTypeName="TravelLink.DAL.TravelLinkDBDataContext" EntityTypeName="" 
        OrderBy="Seq" TableName="TL_Role">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="ldsAdmin" runat="server" 
        ContextTypeName="TravelLink.DAL.TravelLinkDBDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" EnableViewState="False" 
        EntityTypeName="" oninserting="ldsAdmin_Inserting" TableName="TL_Admin">
    </asp:LinqDataSource>
    <dx:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" 
        GridViewID="ASPxGridView1">
            </dx:ASPxGridViewExporter>
</asp:Content>
